cmake_minimum_required(VERSION 3.10)
project(clk_test C)

# 使用 Ninja 生成器
set(CMAKE_GENERATOR "Ninja")

# 设置编译器
set(CMAKE_C_COMPILER "gcc")

# Unity 源文件
set(UNITY_SRC
    ../unity/unity.c
)

# 增加对头文件的依赖
set(HEADER_FILES 
../../src/led.h 
../mock/gpio.h
../mock/print.h
)

# 将测试文件以及被测试文件放在 TEST_SRC 中
set(TEST_SRC test_led.c ../../src/led.c ../mock/soc.c)

# 可执行文件
add_executable(UnitTests ${HEADER_FILES} ${TEST_SRC} ${UNITY_SRC} )

# 包含目录
target_include_directories(UnitTests PRIVATE ../unity)


# 添加自定义目标 'run' 来运行可执行文件
add_custom_target(run
    COMMAND UnitTests
    DEPENDS UnitTests
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "Running UnitTests"
)

